depth first search (search algorithm in AI)
Depth-first search for trees should be distinguished from depth-first search for graphs.
The latter should avoid re-visiting a vertex that has already been visited
Easy to implement with recursive calls, but cost of function calls can be an issue
code:python
def visit(v):
visit(c)
visit(root)
code:python
while stack:
v = stack.pop()
stack.append(c)
---
This page is auto-translated from /nishio/深さ優先探索. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. I'm very happy to spread my thought to non-Japanese readers.